from ftplib import FTP

# 连接到FTP服务器
ftp = FTP()
ftp.connect("192.168.31.67", 21)
ftp.login(user="321", passwd="123")

# 列出FTP服务器上的文件
ftp.retrlines("LIST")

# 下载文件
filename = "Anaconda3-2023.07-1-Windows-x86_64.exe"
local_path = "Anaconda3-2023.07-1-Windows-x86_64.exe"
with open(local_path, "wb") as file:
    ftp.retrbinary("RETR " + filename, file.write)

# # 上传文件
# with open(local_path, "rb") as file:
#     ftp.storbinary("STOR " + filename, file)

# 关闭连接
ftp.quit()